<template>
	<view class="container">


		<view class="content">
			<u-form labelPosition="left" labelWidth="60" :model="prolist" v-if="order.soure=='clear'" >
				<u-form-item label="客户:">
					<u-input v-model="order.business.nickname" disabled />
				</u-form-item>
				<!-- 订单号 -->
				<u-form-item label="订单号:">
					<u--input  v-model="order.code" placeholder="订单号未知" />
				</u-form-item>
				<u-form-item label="订单类型:">
					<u--input  v-model="order.soure_text" placeholder="订单类型未知" />
				</u-form-item>
				<!-- 联系人 -->
				<u-form-item label="联系电话:">
					<u--input disabled type="number" placeholder="联系人电话未知" v-model="order.business.mobile" />
				</u-form-item>
				<!-- 名称 -->
				<u-form-item label="待洗车辆:">
					<u-input v-model="order.carnumberplate" placeholder="待洗车车辆车牌号未知" disabled  />
				</u-form-item>
				<u-form-item label="预约门店:">
					<u-input v-model="order.storename_text" placeholder="预约门店未知" disabled />
				</u-form-item>
				
			
				<!-- 参数1 -->
				<u-form-item label="预约状态:">
					<u-input v-model="order.status_text" placeholder="预约状态未知"  disabled />
				</u-form-item>

				<u-form-item label="退款原因:" prop="description" placeholder="退款原因未知" borderBottom>
					<u-textarea v-model="order.reasons" count disabled></u-textarea>
				</u-form-item>

				<!-- 参数2 -->
				<u-form-item label="服务标题:">
					<u-input disabled v-model="order.carwash.title" placeholder="服务标题未知" />
				</u-form-item>

				<!-- <u-form-item label="参数3:">
					<u-input disabled v-model="order.product.param3" />
				</u-form-item> -->



				<!-- 商品描述 -->
				<u-form-item label="服务简介:" prop="description" borderBottom>
					<u-textarea v-model="order.carwash.content" count disabled></u-textarea>
				</u-form-item>

				<!-- 参数3 -->
				<u-form-item label="申请时间:">
					<u-input v-model="order.backtime_text" disabled />
				</u-form-item>



				<!-- 全款 -->
				<u-form-item label="洗车费:">
					<u-input v-model="order.amount" placeholder="洗车费未知" />
				</u-form-item>



				<!-- 提交按钮 -->

				<u-button text="确定退款" v-if="order.status == 6" icon="pushpin" size="small" type="primary"
					:customStyle="btnStyle" @click="showbutton" />
			</u-form>
			<u-form labelPosition="left" labelWidth="60" :model="prolist" v-if="order.soure=='hire'" >
				<u-form-item label="客户:">
					<u-input v-model="order.business.nickname" disabled />
				</u-form-item>
				<!-- 订单号 -->
				<u-form-item label="订单号:">
					<u--input  v-model="order.code" placeholder="订单号未知" />
				</u-form-item>
				<u-form-item label="订单类型:">
					<u--input  v-model="order.soure_text" placeholder="订单类型未知" />
				</u-form-item>
				<!-- 联系人 -->
				<u-form-item label="联系电话:">
					<u--input disabled type="number" placeholder="联系人电话未知" v-model="order.business.mobile" />
				</u-form-item>
				<!-- 名称 -->
				<u-form-item label="所租车辆:">
					<u-input v-model="order.carnumberplate" placeholder="所租的车辆车牌号未知" disabled  />
				</u-form-item>
				<u-form-item label="预约门店:">
					<u-input v-model="order.storename_text" placeholder="预约门店未知" disabled />
				</u-form-item>
				<u-form-item label="车名:">
					<u-input v-model="order.hirename_text" placeholder="车名未知" disabled />
				</u-form-item>
			
				<!-- 参数1 -->
				<u-form-item label="预约状态:">
					<u-input v-model="order.status_text" placeholder="预约状态未知"  disabled />
				</u-form-item>

				<u-form-item label="退款原因:" prop="description" placeholder="退款原因未知" borderBottom>
					<u-textarea v-model="order.reasons" count disabled></u-textarea>
				</u-form-item>

				<!-- 参数3 -->
				<u-form-item label="申请时间:">
					<u-input v-model="order.createtime_text" disabled />
				</u-form-item>



				<!-- 全款 -->
				<u-form-item label="洗车费:">
					<u-input v-model="order.amount"  placeholder="洗车费未知" />
				</u-form-item>



				<!-- 提交按钮 -->

				<u-button text="确定退款" v-if="order.status == 6" icon="pushpin" size="small" type="primary"
					:customStyle="btnStyle" @click="showbutton" />
			</u-form>

		</view>
		<!-- 消息提醒 -->
		<u-toast ref="notice"></u-toast>
		<u-modal :show="show" @confirm="refundOrder" @cancel="cancel" showCancelButton title="是否确认退款" ref="uModal"
			:asyncClose="true"></u-modal>
	</view>
</template>
  
<script>
export default {
	onLoad(options) {

		this.orderid = options.orderid ? options.orderid : 0



		this.auth = this.$u.auth.check();
		this.info()

	},


	created() {

		this.timer = setInterval(() => {

			let a = this.$u.count.check()

		}, 15000);

	},
	beforeDestroy() {
		clearInterval(this.timer)
	},
	data() {
		return {
			orderid: 0,
			auth: {},
			order: [],
			showbrank: false,
			param1: "",
			param2: "",
			sf: 0,
			show: false,
			description: "",
			price: 0,

			
		};
	},

	methods: {
		showbutton() {
			this.show = true
		},
		cancel() {
			this.show = false
		},

		async refundOrder() {

			this.show = false;
			let data = {
				status: this.order.status,
				adminid: this.auth.id,
				orderid: this.orderid
			}

			let result = await this.$u.api.order.refund(data)

			if (result.code) {
				this.$refs.notice.show({
					type: "success",
					message: result.msg,
					duration: 2200,
					complete: () => {
						setTimeout(() => {
							uni.$u.route({
								type: "reLaunch",
								url: "/pagesB/order/shouhou/index",

							})
						}, 2000)
					}
				})

			} else {
				this.$refs.notice.show({
					type: "error",
					message: result.msg,
					duration: 2000
				})
			}
		},
		async complateConfirm() {
 
			let data = {
				orderid: this.orderid,
				status: 2,
				adminid: this.auth.id
			}
			let result = await this.$u.api.order.complate(data)

			if (result.code) {
				this.$refs.notice.show({
					type: "success",
					message: result.msg,
					duration: 600,
					complete: () => {
						//返回上一个界面
						uni.reLaunch({
							url: "/pagesB/order/index"
						})

					}
				});
			} else {
				this.$refs.notice.show({
					type: "danger",
					message: result.msg,
					duration: 2000,

				});
			}
		},
		async info() {
			let data = {
				orderid: this.orderid,
				adminid: this.auth.id
			}
			let result = await this.$u.api.order.OrderInfo(data)

			if (result.code) {
				this.order = result.data


			} else {
				this.$refs.notice.show({
					type: "danger",
					message: result.msg,
					duration: 2000
				})
			}
		}



	},
};
</script>
  
<style >
.content {
	padding: 20px;
}

.container {
	height: 100%;
	margin: 0 50rpx;
	box-sizing: border-box;
}

.avatar {
	text-align: center;
}

.u-avatar {
	margin: 80rpx auto 40rpx;
}

.xcx {
	width: 200rpx;
	height: 200rpx;
	margin: 80rpx auto 40rpx;
	border-radius: 100%;
	overflow: hidden;
}

.nickname {
	font-size: 14px;
	text-align: center;
}

.title {
	text-align: center;
	margin: 40rpx 0;
	font-size: 14rpx;
}

.avatar .u-upload {
	justify-content: center;
	align-items: center;
	margin: 3em auto;
}
</style>
  